<script type="text/javascript">
	 selectTab('view_entries');
</script>

<?php if($this->is_allow_view || $this->is_allow_vote_view || $this->contest->isEnd()):?>
    <?php if($this->isDisplaySearch):?>
        <div id="search_form" class="search_form">
            <?php echo $this->form;?>
			<?php echo $this->partial('index/_sortControl.phtml',array('query' => $this->pageValues)) ?>
        </div>
    <?php endif;?>
    <?php if (Core_Util::hasMessage($this->contest->getThanksYouMgsKey())): ?>
        <div class="sm_message_panel">
            <p class="header">
                <?php echo $this->escape(Core_Util::getLatestMessage($this->contest->getThanksYouMgsKey())); ?>
            </p>
        </div>
    <?php endif; ?>
	<?php if (Core_Util::hasMessage('404')): ?>
        <div class="sm_message_panel">
            <p class="header">
                <?php echo $this->escape(Core_Util::getLatestMessage('404')); ?>
            </p>
        </div>
    <?php endif; ?>

    <?php if (!empty($this->messages)): ?>
        <div class="sm_message_panel">
            <?php foreach ($this->messages as $value) :?>
            <p class="header">
                <?php echo $this->translate($value); ?>
            </p>
            <?php endforeach;?>
        </div>
    <?php endif; ?>

	<?php if(count($this->paginator)): ?>
		<?php $i = 1; ?>
		<div class="entries_wrapper">
			<ul class="sm_grid_layout">
				<?php foreach($this->paginator as $index =>$entry): ?>
					<li class="nth_<?php echo $index % 4;?>">
						<a href="<?php echo $this->pageUrl(array_merge(array('target' => 'detail', 'id_entry' => $entry->id), $this->extraValues)); ?>">
							<img class="pic_item" src="<?php echo $entry->getThumbnailImageUrl() ?>"
								 title="<?php echo $this->escape($entry->title); ?>"/>
						</a>
						<div class="view_detail">
							<div class="ellipsis title">
                                <a href="<?php echo $this->pageUrl(array_merge(array('target' => 'detail', 'id_entry' => $entry->id), $this->extraValues)); ?>">
                                    <?php echo $this->escape($entry->title); ?>
                                </a>
                            </div>
							<div class="ellipsis">
                                <label>by </label>
                                <a target="_blank" href="<?php echo $entry->getLink();?>" title="<?php echo $this->escape($entry->getFullname());?>">
									<?php echo $this->escape($entry->getFullname());?>
								</a>
							</div>
							<div class="vote_number"><?php echo $this->number($entry->votes,'LABEL_NUM_VOTE'); ?></div>
						</div>
					</li>
				<?php endforeach; ?>
			</ul>
		</div>
	<?php elseif(!empty($this->extraValues['keyword'])):?>
		<div class="sm_message_panel" style="clear: both">
			<p class="header"><?php echo $this->translate('MSG_HAVE_NO_ENTRY_MATCH_YOUR_SEARCH');?></p>
		</div>
	<?php else:?>
		<div class="sm_message_panel">
			<p class="header"><?php echo $this->translate('MSG_HAVE_NO_ENTRY_YET');?></p>
		</div>
	<?php endif; ?>
	<?php
		echo $this->paginationControl($this->paginator, 'Sliding', 'paginatorControl.phtml', array(
			'pageAsQuery' => true,
			'query' => $this->pageValues));
	?>
<?php else:?>
	<div class="sm_message_panel">
        <?php if($this->contest->isWaiting()):?>
        <p class="header"><?php echo sprintf($this->translate('MSG_YOU_CAN_JOIN_AT'), $this->contest->getStartDate("m/d/Y"));?></p>
        <?php else:?>
        <p class="header"><?php echo $this->translate('MSG_DOES_NOT_ALLOW_VIEW_PHASE');?></p>
        <?php endif;?>
	</div>
<?php endif; ?>

<div class="social_plugin">
	<?php echo $this->social->render('shareUrl',
		array(
			'url' => $this->social->getShareUrl('/contest/share/contest/id_page/'.$this->social->getIdPage().'/id_contest/'.$this->contest->id),
			'send'	=> false, 
            'width' => 'auto',
            'layout' => 'full'
		))
	?>
</div>

<script type="text/javascript">
    $(document).ready(function(){
        var url = '<?php echo $this->baseUrl('/contest/index/notify')?>';
        var data = {
            url: "<?php echo $this->social->getShareUrl('/contest/share/contest/id_page/'.$this->social->getIdPage().'/id_contest/'.$this->contest->id); ?>",
            id_contest: "<?php echo $this->contest->id?>"
        };
        detectNewComment(url, data, function(){});
    });
</script>

<?php 
if ('view' == $this->target):
	echo $this->partial('index/scrollTop.phtml'); 
endif;
?>